package com.yk.airline.dao.capturemark.impl;

import com.yk.airline.dao.capturemark.api.ICaptureMarkDao;
import com.yk.airline.dao.common.impl.CommonDaoImpl;
import com.yk.airline.model.CaptureMarkModel;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Project Name:airlinecrawler
 * File Name:CaptureMarkDaoImpl
 * Package Name:com.yk.airline.dao.capturemarkdao.impl
 * Date:2018/1/31 14:35
 * Author:dengtianjia
 * Description:
 * Copyright (c) 2018, 重庆云凯科技有限公司 All Rights Reserved.
 */
@Repository("captureMarkDao")
public class CaptureMarkDaoImpl extends CommonDaoImpl<CaptureMarkModel> implements ICaptureMarkDao {


    @Override
    public List<CaptureMarkModel> findAll() {
        String hql = "from CaptureMarkModel";
        return super.comSearchDao.findByParams(hql,null);
    }

    @Override
    public int findTotalCount() {
        String hql = "select count(id) from CaptureMarkModel";
        return super.comSearchDao.findCount(hql,null);
    }

    @Override
    public CaptureMarkModel findTheLatestMark() {
        String hql ="from CaptureMarkModel c order by c.captureTime desc";
        return super.comSearchDao.findByParamsThenPage(hql,null,0,1).get(0);
    }
}
